package com.example.tomysql

import com.example.tomysql.model.User
import com.example.tomysql.service.UserService
import jakarta.annotation.Resource
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.jdbc.core.JdbcTemplate

@SpringBootTest
class ToMysqlApplicationTests {
    @Resource
    private JdbcTemplate jdbcTemplate;
    @Autowired
    UserService userService;
    @Test
    void taa(){
        User user=new User();
        user.setUserName("阿三");
        user.setStatus("在线");
        // 一个
        int i = userService.addUser(user);
        System.out.println("新增用户成功");
        //
        User user1 =new User();
        user1.setUserName("乌鸦哥");
        user1.setStatus("在线");
        int u = userService.updateUser(user1);
        System.out.println("修改用户成功");
        //
//        List<Object[]> batchArgs = new ArrayList<>();
//        Object[] a1 = {"}
//        Object[] a2 = {"b","在线"};
//        Object[] a3 = {"c","在线"};
//        Object[] a4 = {"d","在线"};
//        batchArgs.add(a1);
//        batchArgs.add(a2);
//        batchArgs.add(a3);
//        batchArgs.add(a4);
//        userService.batchAddUser(batchArgs);
//        System.out.println("批量增加完毕");
//        //查询
//        User user2 = new User();
//        user2.setStatus("在线");
//        int a = userService.countUser(user2);
//        System.out.println("在线用户个数为： "+ a);
//        //
//        List<User> userList = userService.getList(user2);
//        System.out.println("在线用户列表查询成功");
//        //
//        for (User user3 : userList){
//            System.out.println("用户ID："+ user3.getUserId() +",用户名："+
//                    user3.getUserName() + " ，状态："+ user3.getStatus()
//            );
//        }


    }

}
